//
//  SearchForDiseaseDetailForIPadCell.m
//  RoadMaintain
//
//  Created by 岳学坤 on 2017/3/9.
//  Copyright © 2017年 岳学坤. All rights reserved.
//

#import "SearchForDiseaseDetailForIPadCell.h"

@implementation SearchForDiseaseDetailForIPadCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUI];
        
    }
    return self;
}
- (void)setUI{
    UIView *bgView = [[UIView alloc]init];
    bgView.layer.borderColor = [Line_Color CGColor];
    bgView.layer.borderWidth = 1;
    bgView.layer.cornerRadius = 5;
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(6*PadHeightRate);
        make.left.mas_equalTo(23*PadWidthRate);
        make.right.mas_equalTo(-23*PadWidthRate);
        make.bottom.mas_equalTo(-6*PadHeightRate);
    }];
   
    self.titleLab = [[UILabel alloc]init];
    self.titleLab.textColor = Black_Color;
    self.titleLab.font = [UIFont systemFontOfSize:13*PadZitiRate];
    [bgView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(36*PadHeightRate);
        make.left.mas_equalTo(12*PadWidthRate);
        make.right.mas_equalTo(-12*PadWidthRate);
    }];
    
    self.detailTextView = [[JSTextView alloc]init];
    self.detailTextView.textColor = Gray_Color;
    self.detailTextView.delegate = self;
    self.detailTextView.backgroundColor = Bai_Color;
    self.detailTextView.layer.borderColor = [Clear_Color CGColor];
    self.detailTextView.layer.borderWidth = 0;
    self.detailTextView.font = [UIFont systemFontOfSize:12*PadZitiRate];
    [bgView addSubview:self.detailTextView];
    [self.detailTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(40*PadHeightRate);
        make.bottom.mas_equalTo(-10*PadHeightRate);
        make.left.mas_equalTo(12*PadWidthRate);
        make.right.mas_equalTo(-12*PadWidthRate);
    }];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = Line_Color;
    [bgView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(36*PadHeightRate);
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(12*PadWidthRate);
        make.right.mas_equalTo(-12*PadWidthRate);
    }];
    
}
- (void)textViewDidChange:(UITextView *)textView{
    if ([self.detailTextView.text length]>100) {
        self.detailTextView.text = [self.detailTextView.text substringToIndex:100];
    }
    if ([self.delegate respondsToSelector:@selector(detailForIPadCellWithString: indexPath:)]) {
        [self.delegate detailForIPadCellWithString:self.detailTextView.text indexPath:self.indexPath];
    }
}
@end
